﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMaster.Master" AutoEventWireup="true" CodeBehind="Room.aspx.cs" Inherits="MonitorPlan.Admin.Room" %>
<%@ MasterType VirtualPath="~/Admin/AdminMaster.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Room Management</title>
     <script>
        $(document).ready(function () {
            $("a#btnRoom").css("background", "#CCC");
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <%-- sqldatasource to get room --%>
            <asp:SqlDataSource ID="dsRoom" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
                 SelectCommand ="select room.roomid, room.roomname, house.housename, room.description,room.isdeleted from room inner join house on room.houseid=house.houseid where room.isdeleted=0">

            </asp:SqlDataSource>

            <%-- sqldatasource to get house --%>
            <asp:SqlDataSource ID="dsHouse" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
                 SelectCommand="select houseid, housename from house where isdeleted=0"></asp:SqlDataSource>
            <%-- sqldatasource to get house name --%>
            <asp:SqlDataSource ID="dsHouseName" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
                 SelectCommand="select housename from house where isdeleted=0"></asp:SqlDataSource>
            <%-- top menu for view and add new room --%>
              <ul class="nav nav-pills action-buttons">
                <li><asp:LinkButton ID="btnView" runat="server" OnClick="btnView_Click1">
                    <i class="icon icon-view"></i>&nbsp;View</asp:LinkButton></li>
                 <li>
                     <asp:LinkButton ID="btnAdd" runat="server" OnClick="btnAdd_Click">
                         <i class="icon icon-add"></i>&nbsp;Add New
                     </asp:LinkButton>
                 </li>
            </ul>

            <%-- multiview for insert, view, edit and detail view for rooms --%>
            <asp:MultiView ID="mv" runat="server" ActiveViewIndex="0">

                <%-- The view to list all rooms --%>
                <asp:View ID="vRoom" runat="server">
                    <h5 class="text-info">View Rooms</h5>
                    <asp:Repeater ID="rp1" runat="server" DataSourceID="dsRoom" OnItemCommand="rp1_ItemCommand">
                        <HeaderTemplate>
                             <table class="table table-condensed table-striped table-hover">
                                <tr>
                                    <th>Room Id</th>
                                    <th>Room Name</th>
                                    <th>House Name</th>
                                    <th>Description</th>
                                    <th>Actions</th>
                                </tr>
                            
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td><%# Eval("roomid") %></td>
                                <td><%# Eval("roomname") %></td>
                                <td><%# Eval("housename") %></td>
                                <td><%# Eval("description") %></td>
                                <td>
                                    <%-- the command button to edit, delete and view detail for each room --%>
                                    <asp:LinkButton ID="btnDetail" runat="server"
                                        CommandName="detail" CommandArgument='<%# Eval("roomid") %>'>
                                        Detail</asp:LinkButton>&nbsp;
                                     <asp:LinkButton ID="btnEdit" runat="server" 
                                        CommandName="edit" CommandArgument='<%# Eval("roomid") %>'>
                                        Edit</asp:LinkButton>&nbsp;
                                    <asp:LinkButton ID="btnDelete" runat="server"
                                        CommandName="delete" CommandArgument='<%# Eval("roomid") %>' OnClientClick="return confirm('You want to delete it?');">
                                        Delete
                                    </asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </asp:View>

                <%-- The view for add a new room --%>
                <asp:View ID="vAddRoom" runat="server">
                    <h5 class="text-info">Add New Room</h5>
                    <label for="vAddRoom_txtRoomName">Room Name</label>
                    <asp:TextBox ID="vAddRoom_txtRoomName" runat="server" Width="360"></asp:TextBox>
                    <label for="vAddRoom_txtHouseName">House Name</label>
                    <%-- the combobox to bind house name --%>
                    <asp:DropDownList ID="vAddRoom_txtHouseName" runat="server" Width="310" DataSourceID="dsHouse" DataTextField="housename"
                         DataValueField="houseid">

                    </asp:DropDownList>
                     <asp:LinkButton ID="btnAddHouse" runat="server" CssClass="btn btn-link" OnClick="btnAddHouse_Click">
                        <i class="icon-map-marker"></i> New</asp:LinkButton>
                    <label for="vAddRoom_txtRoomDescription">Description</label>
                    <asp:TextBox ID="vAddRoom_txtRoomDescription" runat="server" TextMode="MultiLine" Width="360" Height="60"></asp:TextBox>
                    <br />
                    <%-- The button to save, cancel and go back --%>
                      <asp:LinkButton ID="btnSave" runat="server" CssClass="btn btn-primary btn-small" OnClick="btnSave_Click">
                        <i class="icon-ok-circle icon-white"></i> Save</asp:LinkButton>
                    <asp:LinkButton ID="btnCancel" runat="server" CssClass="btn btn-danger btn-small" OnClick="btnCancel_Click">
                        <i class="icon-remove-sign icon-white"></i> Cancel</asp:LinkButton>
                    <asp:LinkButton ID="btnClose" runat="server" CssClass="btn btn-success btn-small" OnClick="btnClose_Click">
                        <i class="icon-arrow-left icon-white"></i> Back</asp:LinkButton>
                    <br /><br />
                    <div runat="server" id="actionSms"></div>
                </asp:View>

                <%-- view detail room information --%>
                <asp:View ID="vDeatil" runat="server">
                    <h5 class="text-info">View Detail Room</h5>
                    <table class="tbl">
                        <tr>
                            <th>Room Id</th>
                            <td style="width: 40px;">&nbsp;:</td>
                            <td><asp:Label ID="lbRoomId" runat="server" CssClass="text-info"></asp:Label></td>
                        </tr>
                        <tr>
                            <th>Room Name</th>
                             <td>&nbsp;:</td>
                          <td><asp:Label ID="lbRoomName" runat="server" CssClass="text-info"></asp:Label></td>
                        </tr>
                        <tr>
                          <th>House Name</th>
                          <td>&nbsp;:</td>
                          <td><asp:Label ID="lbRoomHouseName" runat="server" CssClass="text-info"></asp:Label></td>
                      </tr>
                        <tr>
                          <th>Description</th>
                          <td>&nbsp;:</td>
                          <td><asp:Label ID="lbRoomDescription" runat="server" CssClass="text-info"></asp:Label></td>
                      </tr>
                         <tr>
                          <th>Is Deleted</th>
                          <td>&nbsp;:</td>
                          <td><asp:Label ID="lbRoomIsDeleted" runat="server" CssClass="text-info"></asp:Label></td>
                      </tr>
                        <tr>
                          <td>
                              <asp:LinkButton ID="btnBack" runat="server" CssClass="btn btn-success btn-small" OnClick="btnBack_Click">
                                  <i class="icon-arrow-left icon-white"></i> Back</asp:LinkButton>
                          </td>
                          <td></td>
                          <td></td>
                      </tr>
                    </table>
                </asp:View>

                <%-- view to edit a room --%>
                <asp:View ID="vEdit" runat="server">
                    <h5 class="text-info">Update Room</h5>
                    <asp:HiddenField ID="txtid" runat="server" />
                    <label for="txtRname">Room Name</label>
                    <asp:TextBox ID="txtRname" runat="server" Width="360"></asp:TextBox>
                    <label for="txtHName">House Name</label>
                     <asp:DropDownList runat="server" ID="txtHName" AutoPostBack="false" Width="310" DataSourceID="dsHouse"
                         DataTextField="housename" DataValueField="houseid"></asp:DropDownList>
                    <asp:LinkButton ID="btnNewHouse" runat="server" CssClass="btn btn-link" OnClick="btnNewHouse_Click">
                        <i class="icon-map-marker"></i> New
                    </asp:LinkButton>

                    <label for="txtRDescription">Description</label>
                    <asp:TextBox ID="txtRDescription" runat="server" TextMode="MultiLine" Width="360" Height="60"></asp:TextBox>
                     <br />
                    <asp:LinkButton ID="btnUpdate" runat="server" CssClass="btn btn-primary btn-small" OnClientClick="return confirm('You want to update?')" OnClick="btnUpdate_Click">
                        <i class="icon-ok-circle icon-white"></i> Update</asp:LinkButton>
                    <asp:LinkButton ID="btnCancelUpdate" runat="server" CssClass="btn btn-danger btn-small" OnClick="btnCancelUpdate_Click">
                        <i class="icon-remove-sign icon-white"></i> Cancel</asp:LinkButton>
                    <div id="updateSms" runat="server"></div>
                </asp:View>
            </asp:MultiView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
